
package com.sausageking.client.merchant.activity;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.inject.Inject;
import com.sausageking.client.MerchantServiceAsync;
import com.sausageking.client.merchant.ui.StickerView;
import com.sausageking.client.mvp.BaseActivity;
import com.sausageking.shared.Merchant;

public class StickerActivity extends BaseActivity
    implements
      StickerView.Presenter {

  @Inject
  private StickerView view;

  @Inject
  private MerchantServiceAsync service;

  private void loadMerchant() {
    service.getById(Long.valueOf(getToken()), new AsyncCallback<Merchant>() {

      @Override
      public void onFailure(Throwable caught) {
        Window.alert("error!!!" + caught.getMessage());
      }

      @Override
      public void onSuccess(Merchant result) {
        view.setMerchant(result);
      }
    });
  }

  @Override
  public String mayStop() {
    return null;
  }

  @Override
  public void print() {

  }

  @Override
  protected void startActivity(AcceptsOneWidget container, EventBus eventBus) {
    view.setPresenter(this);
    container.setWidget(view.asWidget());
    loadMerchant();
  }
}
